package threadlocal.test;

/**
 * @author MI
 * @version 1.0
 * @date 2021/1/9 9:24
 */
public class Mydemo1 {

    ThreadLocal<String> t1 = new ThreadLocal<>();
    private String content;

    public String getContent() {
        // return content;
        return t1.get();
    }

    public void setContent(String content) {
        // this.content = content;
        t1.set(content);
    }


    public static void main(String[] args) {
        Mydemo1 demo = new Mydemo1();
        for (int i = 0; i < 5; i++) {
            new Thread(() -> {
                demo.setContent(Thread.currentThread().getName() + "的数据");
                System.out.println("-------------------");
                System.out.println(Thread.currentThread().getName() + "--" + demo.getContent());
            }).start();
        }
    }
}
